package com.sugon.thread;

import sun.misc.Signal;

import javax.management.monitor.Monitor;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;

/**
 * @author LUOYUAN
 * @create 2019-06-28-16:50
 */
public class MainProcess {

    public static void main(String[] args) {
        //获取程序中所有的线程
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(false, false);
        /*
        6:Monitor Ctrl-Break
        5:Attach Listener
        4:Signal Dispatcher 信号量线程
        3:Finalizer
        2:Reference Handler
        1:main
        */

        for (ThreadInfo threadInfo : threadInfos) {
            System.out.println(threadInfo.getThreadId()+":"+threadInfo.getThreadName());
        }
    }
}
